package com.qf.util;

import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class MD5Util {
            //加密
    public static String md5(String str){
            //获取消息摘要算法
        try {
            MessageDigest md5 = MessageDigest.getInstance("MD5");
            byte [] bytes = str.getBytes("UTF-8");
            for(int i = 0; i < bytes.length;i++){
                bytes[i]-=5;
            }
            //更新数据
            md5.update(bytes);
            //加密
            byte [] digest = md5.digest();
            //返回
            return new BigInteger(1,digest).toString(16);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

    public static void main(String[] args) {
        String s=md5("123");
        System.out.println(s);
    }
}
